package cn.edu.wfit.modules.infomanagement.service.impl;

import java.util.List;
import cn.edu.wfit.common.core.utils.DateUtils;
import cn.edu.wfit.common.core.utils.uuid.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.edu.wfit.modules.infomanagement.mapper.TeacherMapper;
import cn.edu.wfit.modules.infomanagement.domain.Teacher;
import cn.edu.wfit.modules.infomanagement.service.ITeacherService;

/**
 * 老师管理Service业务层处理
 * 
 * @author 韩强
 * @date 2024-12-26
 */
@Service
public class TeacherServiceImpl implements ITeacherService 
{
    @Autowired
    private TeacherMapper teacherMapper;
    @Autowired
    private IdWorker idWorker;

    /**
     * 查询老师管理
     * 
     * @param userId 老师管理主键
     * @return 老师管理
     */
    @Override
    public Teacher selectTeacherByUserId(Long userId)
    {
        return teacherMapper.selectTeacherByUserId(userId);
    }

    /**
     * 查询老师管理列表
     * 
     * @param teacher 老师管理
     * @return 老师管理
     */
    @Override
    public List<Teacher> selectTeacherList(Teacher teacher)
    {

        return teacherMapper.selectTeacherList(teacher);
    }

    /**
     * 新增老师管理
     * 
     * @param teacher 老师管理
     * @return 结果
     */
    @Override
    public int insertTeacher(Teacher teacher)
    {
        teacher.setUserId(idWorker.nextId());
        teacher.setTeacherCode(teacher.getTeacherCode().toUpperCase());
        teacher.setCreateTime(DateUtils.getNowDate());
        return teacherMapper.insertTeacher(teacher);
    }

    /**
     * 修改老师管理
     * 
     * @param teacher 老师管理
     * @return 结果
     */
    @Override
    public int updateTeacher(Teacher teacher)
    {
        teacher.setUpdateTime(DateUtils.getNowDate());
        teacher.setTeacherCode(teacher.getTeacherCode().toUpperCase());
        return teacherMapper.updateTeacher(teacher);
    }

    /**
     * 批量删除老师管理
     * 
     * @param userIds 需要删除的老师管理主键
     * @return 结果
     */
    @Override
    public int deleteTeacherByUserIds(Long[] userIds)
    {
        return teacherMapper.deleteTeacherByUserIds(userIds);
    }

    /**
     * 删除老师管理信息
     * 
     * @param userId 老师管理主键
     * @return 结果
     */
    @Override
    public int deleteTeacherByUserId(Long userId)
    {
        return teacherMapper.deleteTeacherByUserId(userId);
    }

    @Override
    public Teacher selectTeacherByLoginId(int loginId) {
        return teacherMapper.selectTeacherByLoginId(loginId);
    }
}
